//
//  LVCategoryCell.m
//  TestAnimation
//
//  Created by guantianpeng on 13-5-11.
//  Copyright (c) 2013年 baidu.com All rights reserved.
//

#import "LVCategoryCell.h"
#import "ImageDefs.h"
#import "CommonDefines.h"
#import "UIColor-Expanded.h"

//#import "NCColor+Hex.h"

static const CGFloat kLVVerticalPadding = 3;
static const CGFloat kLVHorizontalPadding = 8;

@interface LVCategoryCell()

@property(nonatomic,retain) UIImage *nomarl;
@property(nonatomic,retain) UIImage *pressed;

@end

@implementation LVCategoryCell
@synthesize nomarl = _nomarl;
@synthesize pressed = _pressed;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        _nomarl = [[[UIImage imageNamed:@"lv_cate_btn_normal.png" ]stretchableImageWithLeftCapWidth:11 topCapHeight:11]retain];
        _pressed = [[kLVImageCategoryBtnPressed stretchableImageWithLeftCapWidth:11 topCapHeight:0]retain];
    }
    
    return self;
}

- (void)setCateCellInfo:(CategoryCellInfo *)cateCellInfo
{
    if (_cateCellInfo == cateCellInfo) {
        return;
    }
    [_cateCellInfo release];
    _cateCellInfo = [cateCellInfo retain];
    
    self.titleLabel.font = [UIFont fontWithName:kFontNameHeiti size:13];
    self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

    [self setTitle:_cateCellInfo.name forState: UIControlStateNormal];
    // set color
    [self setTitleColor:[UIColor colorWithHex:0XFF6A6D72] forState:UIControlStateNormal];
    [self setTitleColor:[UIColor colorWithHex:0XFFFFFFFF] forState:UIControlStateSelected];
    [self setTitleColor:[UIColor colorWithHex:0XFFFFFFFF] forState:UIControlStateHighlighted];
    [self setTitleColor:[UIColor colorWithHex:0XFFFFFFFF] forState:UIControlStateHighlighted | UIControlStateSelected];
    
    // set image
//    [self setBackgroundImage:_nomarl forState:UIControlStateNormal];
    [self setBackgroundImage:_pressed forState:UIControlStateSelected];
    [self setBackgroundImage:_pressed forState:UIControlStateHighlighted];
    [self setBackgroundImage:_pressed forState:UIControlStateHighlighted | UIControlStateSelected];
    
    CGSize size = [_cateCellInfo.name sizeWithFont:self.titleLabel.font];
    CGRect bounds = CGRectMake(0, 0, size.width + kLVHorizontalPadding * 2, size.height + kLVVerticalPadding * 2);
    self.bounds = bounds;
}

- (void)dealloc
{
    self.cateCellInfo = nil;
    self.pressed = nil;
    self.nomarl = nil;
    
    [super dealloc];
}


@end


@implementation CategoryCellInfo

@synthesize name = _name;
@synthesize cId = _cId;

- (void)dealloc
{
    self.name = nil;
    self.cId = nil;
    
    [super dealloc];
}

@end
